package node

import (
	"context"
	"krm_pro/config"

	"github.com/gin-gonic/gin"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var nodeSet = config.ClientSet.CoreV1().Nodes

func NodeList(r *gin.Context) {
	node, err := nodeSet().List(context.TODO(), metav1.ListOptions{})
	if err != nil {
		r.JSON(200, gin.H{
			"status":  400,
			"message": "node list false",
		})
		return
	}
	r.JSON(200, gin.H{
		"status":  200,
		"message": "Node list completed",
		"Node":    node,
	})
}
